const path = require('path')
function resolve (dir) {
  return path.join(__dirname, dir)
}
module.exports = {
// svg设置
  chainWebpack (config) {
    // 排除icons目录，.end()回到上一级
    config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end()
    // 新增icons规则，设置svg-sprite-loader
    config.module
      .rule('icons')
      .test(/\.svg$/).include.add(resolve('src/assets/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({ symbolId: 'icon-[name]' })
      .end()
  },
  css: {
    sourceMap: true,
    loaderOptions: {
      sass: {
        prependData: `
        @import '~@/assets/style/scss/px2rem.scss';
        @import '~@/assets/style/scss/mixin.scss';
        @import '~@/assets/style/scss/_variable.scss';
      `
      }
    }
  },
  devServer: {
    host: '0.0.0.0',
    port: 8080,
    disableHostCheck: true
  }
}

